#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;

int n, a, b;
int ret1 = INT_MIN;
int ret2 = INT_MAX;
bool check1(int mid)
{
    return a/mid<=b;
}
bool check2(int mid)
{
    return a/mid>=b;
}
void solve()
{
    cin >> a >> b;
    //枚举所有可能的v
    int l=1,r=a,ans=-1;
    //枚举找到v的最小值
    while(l<=r)
    {
        int mid=(r-l)/2+l;
        


        if(check1(mid))
        {
            ans=mid;
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    ret1=max(ret1,ans);

     l=1,r=a,ans=-1;
    //枚举找到v的最大值
    while(l<=r)
    {
        int mid=(r-l)/2+l;
        if(check2(mid))
        {
            ans=mid;
            l=mid+1;
        }
        else
        {
            r=mid-1;
        }
    }
    ret2=min(ret2, ans);

}
int main()
{
    cin >> n;
    while(n--)
    {
        solve();
    }
    cout<<ret1<<" "<<ret2;
    return 0;
}